#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

#define SIGNAL_NAME     SIGUSR1

static void handler1(int sig);

int main(void)
{
    int i;
    pid_t pid, ppid;

    ppid = getpid();

    signal(SIGNAL_NAME, handler1);

    pid = fork();

    if (-1 == pid) {
        perror("fork()");
        return 1;
    }

    if (0 == pid) {
        printf("[%d]hello\n", getpid());
        kill(ppid, SIGNAL_NAME);
        pause();
        printf("[%d]bye bye\n", getpid());
        exit(0);
    } else {
        pause();
        printf("[%d]world\n", getpid());
        kill(pid, SIGNAL_NAME);
        wait(NULL);
    }

    return 0;
}

static void handler1(int sig)
{
    
}

